package com.shen.pojo.draw;

/**
 * Author:shen
 * CreateDate:2020/5/13.
 * Function:
 */
public class Rectangle implements Graphics {
    private double a;
    private double b;

    public Rectangle() {
    }

    public Rectangle(double a, double b) {
        this.a = a;
        this.b = b;
    }

    public double getA() {
        return a;
    }

    public void setA(double a) {
        this.a = a;
    }

    public double getB() {
        return b;
    }

    public void setB(double b) {
        this.b = b;
    }
    private boolean isRectangle(){
        return a>0&&b>0 ? true:false;
    }
    @Override
    public double perimeter() {
        return isRectangle() ? (a+b)*2:-1;
    }

    @Override
    public double area() {
        return isRectangle() ? a*b:-1;
    }
}
